import Vue from 'vue'
import Router from 'vue-router'
import Main from '@/views/main'
import Login from '@/components/login/login'
import User from '@/views/system/user'
import WorkFlow from "@/views/workflow"
import WorkFlowEdit from "@/views/workflowEdit"
import notFound from '@/views/500'
import Org from '@/views/system/org'
import Role from '@/views/system/role'
import Resources from "@/views/system/resources"
import Position from "@/views/system/position"
import Dict from "@/views/system/dict"
import Boardroom from "@/views/system/boardroom"
import Folder from "@/views/system/folder"
import formBuild from "@/views/system/formBuild"
import formList from "@/views/system/formList"
import formEdit from "@/views/system/formEdit"
import Setting from "@/views/system/setting"
import Document from "@/views/system/document"
import Monitor from "@/views/system/monitor"

Vue.use(Router)


//所有权限通用路由表
//如首页和登录页和一些不用权限的公用页面
export const constantRouterMap = [{
		path: '/login',
		name: '登录页',
		component: Login
	},
	{
		path: '/',
		name: '首页',
    component: Main,
    redirect:'/index',
    children:[
      { path:'/index',name:'首页',component:Org },
	    { path:'/org',name:'组织架构',component:Org },
	    { path:'/position',name:'部门职位',component:Position },
      { path:'/user',name:'用户管理',component:User },
      { path:'/role',name:'角色管理',component:Role },
      { path:'/workflow',name:'流程管理',component: WorkFlow},
      { path:'/workflow/:id',name:'流程配置',component: WorkFlowEdit},
      { path:'/resources', name:'菜单管理',component: Resources },
	    { path:'/monitor', name:'流程监控',component: Monitor },
      { path:'/dict', name:'系统字典',component: Dict },
      { path:'/boardroom', name:'会议室字典',component: Boardroom },
      // { path:'/form', name:'表单管理', redirect:"/formBuild", children:[
	  // ]},
	  { path:'/folder', name:'系统字典',component: Folder },
	  { path:'/setting',name:'安全设置',component: Setting },
      {path:'/formBuild', name:"表单设计",component: formBuild},
      {path:'/formList', name:"表单列表",component: formList},
		{path:'/formEdit/:id', name:"表单编辑",component: formEdit},
		{path:'/document/:attachmentId/:suffixType',name:"预览页面",component:Document},
    ]
  },
  {
		path: '/pages',
		name: '办公流程',
		component: Main,
		children: [{
			path: 'resources',
			name: '工作签报',
			component: Login
		}, ]
	},
	{
		path: "/500",
		name: "页面建设中",
		component: notFound
	}
]

// 实例化vue的时候只挂载constantRouter
export default new Router({
	routes: constantRouterMap
});

//异步挂载的路由
//动态需要根据权限加载的路由表
export const asyncRouterMap = [{
		path: '/permission',
		component: Org,
		name: '权限测试',
		meta: {
			role: ['admin', 'super_editor']
		}, //页面需要的权限
		children: [{
			path: 'index',
			component: Org,
			name: '权限测试页',
			meta: {
				role: ['admin', 'super_editor']
			} //页面需要的权限
		}]
	},
	{
		path: '*',
		redirect: '/404',
		hidden: true
	}
];
